<?php

namespace app\cms\home;

use think\Db;
use think\Request;


class Index extends Common
{

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->assign('menu', 'index');
    }

    public function index()
    {
        $data = Db::name('cms_document')
            ->order('id desc')
            ->paginate(7);
        $dataArr = $data->items();
        foreach ($dataArr as $key => $v) {
            $dataArr[$key]['content'] = Db::name('cms_document_article')
                ->where(['aid' => $v['id']])
                ->find();
        }
        $this->assign('data', $dataArr);
        return $this->fetch();
    }
}